<%--
  Created by IntelliJ IDEA.
  User: mr.chan
  Date: 2022/4/30
  Time: 下午2:14
  To change this template use File | Settings | File Templates.
--%>

<!DOCTYPE html>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt"%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@page isELIgnored="false" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>修改用户</title>
    <link rel="stylesheet"
          href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script
            src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <style type="text/css">
        .paz {
            position: absolute;
            top: 10px;
            right: 5px;
            z-index: 10;
        }
    </style>
    <script type="text/javascript">
        $(function() {
            $("#frm").submit(function() {
                $('[type=submit]').attr("disabled", "disabled");
                $.ajax({
                    url : '${pageContext.request.contextPath}'+ '/user/edit',
                    type : "POST",
                    data : $("#frm").serialize(),
                    success : function() {
                        $("#msg").show();
                        setTimeout("$('#msg').hide();location.href='${pageContext.request.contextPath}'+'/user/list'",3000);
                    },
                    error : function() {
                        $("#msg").show("slow");
                    }

                });
                return false;
            })
        })
    </script>
</head>
<body>
<!--成功的提示框  -->
<!-- Large modal -->

<!-- Small modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-sm">Small modal</button>

<div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
    <div class="modal-dialog modal-sm" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                <h4 class="modal-title" id="mySmallModalLabel">Small modal</h4>
            </div>
            ...
        </div>
    </div>
</div>

<div id="msg"
     style="width: 60%; margin: 0px auto; margin-top: 10px; display: none;">
    <div class="alert alert-warning alert-dismissible paz" role="alert"
         data-dismiss="alert">
        <button type="button" class="close" aria-label="Close">
            <span aria-hidden="true">&times;</span>
        </button>
        <strong>提示!</strong> 修改 成功！！！
    </div>
    <div style="clear: both;"></div>
</div>
<div style="width: 80%; margin: 0px auto; margin-top: 50px;">
    <form class="form-horizontal" method="post" id="frm">
        <input type="hidden" name="id" value="${detail.id}">
        <!-- ${pageContext.request.contextPath}/user/add -->
        <div class="form-group">
            <label for="username" class="col-sm-2 control-label">用户名：</label>
            <div class="col-sm-10">
                <input type="text" name="username" class="form-control"
                       id="username" placeholder="用户名" value="${detail.username}">
            </div>
        </div>
        <div class="form-group">
            <label for="birthday" class="col-sm-2 control-label">生日：</label>
            <div class="col-sm-10">
                <input type="date" name="birthday" class="form-control" id="birthday"
<%--                       value="2020-2-2"--%>
                       value="<fmt:formatDate value='${detail.birthday}' pattern='yyyy-MM-dd'/>"
                       placeholder="你的生日">
            </div>
        </div>

        <div class="form-group">
            <label for="sex" class="col-sm-2 control-label">性别：</label>
            <div class="col-sm-10">
                <div class="radio">

                    <label> <input type="radio" name="sex" value="男"
                                   <c:if test="${detail.sex=='男'}">checked="checked"</c:if> />男
                    </label> <label> <input type="radio" name="sex" value="女"
                                            <c:if test="${detail.sex=='女'}">checked="checked"</c:if> />女
                </label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label for="address" class="col-sm-2 control-label">住址：</label>
            <div class="col-sm-10">
                <input type="text" name="address" class="form-control"
                       value="${detail.address}" id="address" placeholder="填写你的住址">
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-default">修改</button>
            </div>
        </div>
    </form>
</div>
</body>
</html>
